package com.dqhl.community.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.bm.library.PhotoView;
import com.dqhl.community.R;
import com.dqhl.community.base.BaseActivity;

import org.xutils.image.ImageOptions;
import org.xutils.x;

/**
 * Created by Guanlucang on 2016/8/8.
 * 显示大图片的activity
 */
public class ImageShowerActivity extends BaseActivity {
    private String imgPath;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_shower);
        imgPath = getIntent().getStringExtra("img_path");
        ImageOptions options = new ImageOptions.Builder()
                // 是否忽略GIF格式的图片
                .setIgnoreGif(false)
                // 图片缩放模式
                .setImageScaleType(ImageView.ScaleType.FIT_CENTER)
                // 下载中显示的图片
                .setLoadingDrawableId(R.drawable.xsearch_loading)
                // 下载失败显示的图片
                .setFailureDrawableId(R.drawable.xsearch_loading)
                // 得到ImageOptions对象
                .build();
        PhotoView photoView = (PhotoView) findViewById(R.id.iv_pic);
        photoView.enable();
        photoView.setAnimaDuring(1);
        float maxScale = photoView.getMaxScale();
        photoView.setMaxScale(maxScale);
        x.image().bind(photoView, imgPath, options);

        photoView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }
}
